package com.mapreduce.partitioner;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;

import java.io.IOException;

public class SalaryTotalMain {

    public static void main(String[] args) throws IOException, ClassNotFoundException, InterruptedException {
        //1. 创建一个job和任务入口(指定主类)
        Job job = Job.getInstance(new Configuration());
        job.setJarByClass(SalaryTotalMain.class);
        // 2. 指定job的mapper和输出的类型<k2 v2>
        job.setMapperClass(SalaryTotalMapper.class);
        job.setMapOutputKeyClass(IntWritable.class);
        //job.setMapOutputValueClass(IntWritable.class);
        job.setMapOutputValueClass(Employee.class);
        //3. 指定job的reducer和输出的类型<k4  v4>
        job.setReducerClass(SalaryTotalReducer.class);
        job.setOutputKeyClass(IntWritable.class);
        job.setOutputValueClass(IntWritable.class);
        job.setPartitionerClass(DeptPartitioner.class);
        job.setNumReduceTasks(3);
        //4. 指定job的输入和输出路径
//        FileInputFormat.setInputPaths(job,new Path(args[0]));
//        FileOutputFormat.setOutputPath(job,new Path(args[1]));
        FileInputFormat.setInputPaths(job,new Path("D:\\wordcount\\input\\emp.csv"));
        FileOutputFormat.setOutputPath(job,new Path("D:\\wordcount\\output\\salaryTo118"));
       // 5. 执行job
        job.waitForCompletion(true);

    }
}
